if(!function(){window.console||(window.console={});for(var i,o=["log","info","warn","error","debug","trace","dir","group","groupCollapsed","groupEnd","time","timeEnd","profile","profileEnd","dirxml","assert","count","markTimeline","timeStamp","clear"],e=0;e').appendTo("head")},Codibook._isNativeAdapterInited=!1,Codibook._nativeAdapterInitedWaiters=[],Codibook._nativeAdapterInited=function(){Codibook._isNativeAdapterInited=!0,Codibook._nativeAdapterInitedWaiters.forEach(function(o){Codibook.nextTick(o)}),Codibook._nativeAdapterInitedWaiters=[]},Codibook.onNativeAdapterInit=function(o){Codibook._isNativeAdapterInited?Codibook.nextTick(o):Codibook._nativeAdapterInitedWaiters.push(o)},Codibook._lastCallId=0,Codibook.generateCallId=function(){return++Codibook._lastCallId},window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.codibook&&(Codibook.isApp=!0,Codibook.isIOSApp=!0,Codibook._iOSNativeCallbacks={},Codibook._iOSNativeCallback=function(o,e,i){var t=Codibook._iOSNativeCallbacks[e];t&&(delete Codibook._iOSNativeCallbacks[e],t(i))},Codibook.registerIOSNativeFunctions=function(o){Codibook.nativeAdapter||(Codibook.nativeAdapter={}),o.forEach(function(i){Codibook.nativeAdapter[i]=function(){var o=Codibook.generateCallId(),e=Array.prototype.slice.call(arguments);return 0Date.now()?o.data:null},Codibook.cacheData=function(o,e){e={data:e,cachedAt:Date.now()};Codibook._cacheDataInterface(o,JSON.stringify(e))},Codibook.removeCacheData=function(o){Codibook._removeCacheDataInterface(o)},Codibook.kkvs={_notExists:window.Symbol&&window.Symbol()||void 0,_prefix:"__KKVS_AMTdvMlW7kIQrqAQ__",_keyDelimiter:"__KKVS_Ve8hOMncQn5bkksH__",_convertToSingleKey:function(o,e){return this._prefix+o+this._keyDelimiter+e},_convertFromSingleKey:function(o){return 0!==o.indexOf(this._prefix)?null:o.replace(this._prefix,"").split(this._keyDelimiter)},_wrapValues:function(o,e){return o.map(function(o){return JSON.stringify({value:o,expires:void 0===e?null:Date.now()+e})})},_listKeys:function(){for(var o=[],e=0;e div").hide(),i.find(".fblogin").show()):Codibook.regexLineUserId.test(o)&&(i.find("form.login > div").hide(),i.find(".linelogin").show())),Codibook.loadModule("ui").then(function(){Codibook.dialog(i,a),Codibook.initEmailValidationDialog({onSubmit:o=>{Codibook.api("signin",{method:"POST",data:$("form.login").serialize()+"&code="+o.verify_code}).then(function(o){o.err?Codibook.toastErrorMessage(o.msg):(o=$("form.login .return_to").val())?location.href=o:location.reload()})}})})};let _validationRetryTimer;Codibook.showValidationDialog=function(o){o=o||{};const e=$("#validation"),i=$(".retry");let t=60;clearInterval(_validationRetryTimer),_validationRetryTimer=setInterval(function(){if(--t<=0)return clearInterval(_validationRetryTimer),void i.prop("disabled",!1).text($.i18n._("resend code"));i.text($.i18n._("resend code")+`(${t})`)},1e3),i.prop("disabled",!0);var n={width:460,height:430,dialogClass:"notitle",focusOn:"input.verify_code",open:function(){$("body").addClass("modal-open"),$("#email_sent_to").text(o.email)},close:function(o,e){$("body").removeClass("modal-open")}};Codibook.loadModule("ui").then(function(){Codibook.dialog(e,n)})},Codibook.acquireDOMLock=function(o,e){return!o.data(e="__codibook_lock__"+e)&&(o.data(e,!0),!0)},Codibook.releaseDOMLock=function(o,e){o.removeData(e="__codibook_lock__"+e)},Codibook.callback1=function(o){o&&(o=o instanceof Array?o:[o]).forEach(function(o){o&&(o.message&&Codibook.toastMessage(o.message,{type:"error"}),console.error(o))})},Codibook.readyAndCall=function(o,e){Codibook.runOnceOn(function(){return"function"==typeof window[o]},"function"==typeof e?e:function(){window[o].apply(null,e)})},Codibook.ga=function(){Codibook.readyAndCall("ga",arguments)},Codibook.gtag=function(){window.dataLayer?window.dataLayer.push(arguments):console.error("GTM not started. Ignore arguments",arguments)},Codibook.fbq=function(){Codibook.readyAndCall("fbq",arguments)},$(window).on("beforeunload unload",function(){Codibook.unloadingState=!0}),Codibook.parseAJAXError=function(o,e,i){var t=o.responseJSON||i.responseJSON,n=(void 0!==o.readyState?o:i).readyState,o=(void 0!==o.status?o:i).status;let a=t&&t.message;return{responseJSON:t,message:a=a||(504===o?"Response timeout (HTTP 504)":"Unknown error (rs: "+n+", hs: "+o+")"),httpStatus:o,readyStatus:n}},Codibook.onAjaxError=function(o,e,i){var t,n,a;Codibook.unloadingState||(n=(t=Codibook.parseAJAXError(o,e,i)).message,a=t.httpStatus,"timeout"==e?Codibook.toastMessage("Request timed out",{type:"error",killer:!0}):401==a||o.responseJSON&&401==o.responseJSON.errorCode?(Codibook.showLoginDialog(),Codibook.user_id&&(Codibook.user_id=null,Codibook.bindLoginDialog())):502==a||404==a||"abort"==e?console.error([n,o,e,i,t]):(Codibook.toastErrorMessage(n),console.error([o,e,i,t])))},$.ajaxSetup({error:Codibook.onAjaxError}),Codibook.api=function(o,i,e,t){var n=(i=i||{}).notyMessage&&Codibook.toastMessage(i.notyMessage,{timeout:!1}),a="_blank"===i.followRedirect&&window.open("about:blank"),o=$.ajax({url:"/"===o[0]?o:"/api/v1/"+o,type:i.method||i.type,headers:i.headers,data:i.data,success:e||i.success,error:t||i.error});return(i.reloadPageOnSuccess||i.followRedirect||n||i.onSuccessNoty)&&o.then(function(o){var e;return i.onSuccessNoty&&Codibook.toastMessage(i.onSuccessNoty),i.followRedirect&&(e=o&&o.redirectTo,a?e?a.location.href=e:a.close():e&&(window.location.href=e)),i.reloadPageOnSuccess&&(i.preserveScrollLocation&&Codibook.reserveScrollLocation(),window.location.reload()),n&&n.close(),o}),o},Codibook.fetch=function(o,e){e=e||{};var i=Object.assign({"x-requested-with":"XMLHttpRequest"},e.headers);return fetch("/"===o[0]?o:"/api/v1/"+o,Object.assign({},e,{headers:i})).then(function(e){return e.ok?e:e.json().then(function(o){i=o},function(o){i={}}).then(function(){var o=i.message||e.statusText||"Unknown Error";throw Codibook.toastErrorMessage(o),new Error(o)});var i})},Codibook.logDebug=function(o,e){Codibook.api("/log/debug",{type:"POST",data:{message:o,data:e}})},Codibook.logError=function(o,e){Codibook.api("/log/error",{type:"POST",data:{message:o,data:e}})},"undefined"==typeof JSON&&Codibook.loadModule("json"),void 0===$.noty&&Codibook.loadModule("noty",function(){$.noty.themes.codibook={name:"codibook",style:function(){switch(this.$bar.css({overflow:"hidden",background:"#fff",padding:"16px 0",fontSize:"16px",borderRadius:0,marginTop:"20px",borderColor:"#ff2477",textAlign:"center"}),Codibook.agent.mobile&&this.$bar.css({marginTop:"10px",fontSize:"14px",padding:"15px 0"}),this.options.type){case"alert":case"notification":this.$bar.css({backgroundColor:"#333",color:"#fff",opacity:.9,"text-shadow":"1px 1px #000"});break;case"warning":this.$bar.css({backgroundColor:"#333",color:"#fff",opacity:.9}),this.$buttons.css({borderTop:"1px solid #FFC237"});break;case"error":this.$bar.css({backgroundColor:"red",borderColor:"darkred",color:"#FFF"}),this.$message.css({fontWeight:"bold"}),this.$buttons.css({borderTop:"1px solid darkred"});break;case"information":this.$bar.css({backgroundColor:"#57B7E2",borderColor:"#0B90C4",color:"#FFF"}),this.$buttons.css({borderTop:"1px solid #0B90C4"});break;case"success":this.$bar.css({backgroundColor:"lightgreen",borderColor:"#50C24E",color:"darkgreen"}),this.$buttons.css({borderTop:"1px solid #50C24E"});break;default:this.$bar.css({backgroundColor:"#FFF",borderColor:"#CCC",color:"#444"})}},callback:{onShow:function(){$.noty.themes.defaultTheme.helpers.borderFix.apply(this)},onClose:function(){$.noty.themes.defaultTheme.helpers.borderFix.apply(this)}}},$.noty.defaults={layout:"topCenter",theme:"codibook",type:"alert",text:"",dismissQueue:!0,template:'
',animation:{open:{opacity:"toggle"},close:{opacity:"toggle"},easing:"swing",speed:100},timeout:5e3,force:!1,modal:!1,maxVisible:1,killer:!1,closeWith:["click"],callback:{onShow:function(){},afterShow:function(){},onClose:function(){},afterClose:function(){}},buttons:!1},Codibook._toastMessageOriginal&&(Codibook.toastMessage=Codibook._toastMessageOriginal,delete Codibook._toastMessageOriginal)}),Codibook.toastMessage=function(o,e,i){return i&&i.noty&&i.noty.close(),noty(Object.assign({text:o},e))},Codibook.toastErrorMessage=function(o,e){return Codibook.toastMessage(o,Object.assign({type:"error",killer:!0,timeout:20